import moment from 'moment'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')


export function dateFormat(date: string | number | Date, format = 'YYYY-MM-DD HH:mm:ss'):string{
    return moment(date).format(format)
}

//Date(1726588800000)  =>  2025-06-10
export function formatDateString(dateString: string, format = 'YYYY-MM-DD'): string {
    const timestamp = parseInt(dateString.match(/\d+/)?.[0] || '0', 10);
    return moment(timestamp).format(format);
}